﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using AudioCore.Biz;
using AudioBookWS.ServiceEntity;
using AudioBookWS.ServiceUtil;
using AudioCore.Entity;
using AudioCore.Common;

namespace AudioBookWS
{
    /// <summary>
    /// Summary description for audio
    /// </summary>
    [WebService(Namespace = "http://audiobook.vn/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class Audio : System.Web.Services.WebService
    {
        #region static variable
        private static CategoryBiz bizCategory = new CategoryBiz();

        private static ArticleBiz bizArticle = new ArticleBiz();

        private static ArticlePartBiz bizArticlePart = new ArticlePartBiz();

        private static VisitedBiz bizVisited = new VisitedBiz();

        private static AccountBiz bizAccount = new AccountBiz();

        private static FavoriteBiz bizFavorite = new FavoriteBiz();

        public delegate void AsynchronousHandler(object[] param);

        #endregion

        #region Constants
        private const int ROOT_CATEGORY_ID = Constant.ROOT_CATEGORY_ID;

        private const int TOP_ARTICLE_ON_CATEGORY = 5;

        private const int DEFAULT_PAGE_SIZE = 15;

        private const int DEFAULT_PAGE_NUMBER = 1;

        private const int DEFAULT_RATE = 3;

        private const int MAX_RATE = 5;

        #endregion

        public Audio()
        {
            //do nothing
        }

        #region Web Method

        [WebMethod(Description = "Login method. u = UserName, p1 = Password, p2 = NewPass, e = Email, y = ContentType, v = Version")]
        public List<L> l(string u, string p1, string p2, string e, string y, string v)
        {
            int ty = 0;
            if (!int.TryParse(y, out ty))
            {
                return null;
            }

            WSConstants.ContentType type = (WSConstants.ContentType)ty;
            switch (type)
            {
                case WSConstants.ContentType.UserLogin:
                    return RequestLogin(u, p1);

                case WSConstants.ContentType.UserChangePass:
                    return RequestUserChangePass(u, p1, p2);

                case WSConstants.ContentType.UserInfo:
                    return RequestUserInfo(u, p1);

                case WSConstants.ContentType.UserRegister:
                    return RequestUserRegister(u, p1, e);

                case WSConstants.ContentType.UserGetPassword:
                    return RequestUserGetPassword(e);
            }
            return null;
        }

        [WebMethod(Description = "Get content of one Category or Article. u=UserID, pw=Password, i=ItemID, y=ContentType, k=Keyword, p=PageIndex, n=PageSize, t=Thumbnail")]
        public List<I> c(string u, string pw, string i, string y, string k, string p, string n, string t)
        {
            int accountID, itemID, pageSize, pageIndex;
            int itemTypeID;
            string keyWord = k;

            if (!int.TryParse(u, out accountID))
            {
                accountID = 0;
            }

            if (!int.TryParse(p, out pageIndex))
            {
                pageIndex = DEFAULT_PAGE_NUMBER;
            }
            //
            pageIndex -= 1;

            if (!int.TryParse(n, out pageSize))
            {
                pageSize = DEFAULT_PAGE_SIZE;
            }

            if (!string.IsNullOrEmpty(keyWord))
            {
                //search article
                return RequestSearchArticle(accountID, keyWord.Trim(), pageIndex, pageSize);
            }
            else
            {
                if (!int.TryParse(y, out itemTypeID))
                {
                    return new List<I>() { WSUtils.GetNotifyItem(GlobalParam.InvalidRequest) };
                }

                if (!int.TryParse(i, out itemID) && (itemTypeID != (int)WSConstants.ContentType.Hit
                    && itemTypeID != (int)WSConstants.ContentType.FavoriteDeleteAll
                    && itemTypeID != (int)WSConstants.ContentType.FavoriteList))
                {
                    return new List<I>() { WSUtils.GetNotifyItem(GlobalParam.InvalidRequest) };
                }

                WSConstants.ContentType type = (WSConstants.ContentType)itemTypeID;
                switch (type)
                {
                    // y = 1
                    case WSConstants.ContentType.Category:
                        return RequestCategory(accountID, itemID, pageIndex, pageSize);

                    // y = 2
                    case WSConstants.ContentType.Article:
                        return RequestArticle(accountID, itemID, pageIndex, pageSize);

                    //y = 3
                    case WSConstants.ContentType.ArticlePart:
                        return RequestArticlePart(accountID, itemID);

                    //y = 4
                    case WSConstants.ContentType.Hit:
                        return RequestTopHitArticle(accountID);

                    //y = 5
                    case WSConstants.ContentType.FavoriteList:
                        return RequestFavoriteArticle(accountID, pageIndex, pageSize);

                    //y = 6
                    case WSConstants.ContentType.FavoriteAdd:
                        return RequestFavoriteAdd(accountID, pw, itemID);

                    //y = 7
                    case WSConstants.ContentType.FavoriteDelete:
                        return RequestFavoriteDelete(accountID, pw, itemID);

                    //y = 8
                    case WSConstants.ContentType.FavoriteDeleteAll:
                        return RequestFavoriteDeleteAll(accountID, pw);

                    // y = 9
                    case WSConstants.ContentType.Download:
                        return RequestDownload(accountID, pw, itemID);

                    // y = 10
                    case WSConstants.ContentType.Rating:
                        return RequestRating(accountID, pw, itemID, pageSize);

                    default:
                        return null;
                }
            }
        }
        #endregion Web Method

        #region Process request

        private List<I> RequestCategory(int accountID, int categoryID, int pageIndex, int pageSize)
        {
            List<I> result = new List<I>();
            List<I> lstCat = GetCategory(categoryID);
            List<I> lstTmp = new List<I>();
            int cOut = 0;

            //Category do not has any sub
            if (lstCat.Count == 0)
            {
                //Get list article and then paging the item
                lstTmp = GetListArticle(accountID, categoryID, pageIndex, pageSize, ref cOut);

                if (cOut == 0)
                {
                    //Add counter item
                    result.Add(WSUtils.GetCounterItem(-1));
                }
                else
                {
                    //Add counter item
                    result.Add(WSUtils.GetCounterItem(cOut));
                }

                //Add list articles item
                result.AddRange(lstTmp);
            }
            else
            {
                //Add counter item is number of sub category
                result.Add(WSUtils.GetCounterItem(lstCat.Count * -1));

                // Add list article
                result.AddRange(GetTopArticle(accountID, TOP_ARTICLE_ON_CATEGORY));

                //Add categories item
                result.AddRange(lstCat);
            }
            return result;
        }

        private List<I> RequestArticle(int accountID, int articleID, int pageIndex, int pageSize)
        {
            List<I> result = new List<I>();
            int cOut = 0;

            List<I> lstTmp = GetListArticlePart(accountID, articleID, pageIndex, pageSize, ref cOut);

            I article = GetArticleByID(articleID);
            if (article == null)
            {
                //Add notify item
                result.Add(WSUtils.GetNotifyItem(GlobalParam.InvalidRequest));
            }
            else
            {
                // Set visited
                AsynchronousHandler handlerVisited = new AsynchronousHandler(ProcessVisitedArticle);
                handlerVisited.BeginInvoke(new object[] { accountID, articleID }, null, null);

                // Add counter item
                result.Add(WSUtils.GetCounterItem(cOut));

                //Add article model
                result.Add(article);

                //Add article parts
                result.AddRange(lstTmp);
            }
            return result;
        }

        private List<I> RequestArticlePart(int accountID, int articlePartID)
        {
            List<I> result = new List<I>();

            AccountEntity enAccount = bizAccount.GetAccountByID(accountID);
            if (enAccount == null)
            {
                result.Add(WSUtils.GetNotifyItem(GlobalParam.InvalidRequest));
                return result;
            }

            ArticlePartEntity enPart = bizArticlePart.GetArticlePartByID(accountID, articlePartID);
            if (enPart == null)
            {
                result.Add(WSUtils.GetNotifyItem(GlobalParam.InvalidRequest));
                return result;
            }
            // Set visited
            AsynchronousHandler handlerVistied = new AsynchronousHandler(ProcessVisitedArticlePart);
            handlerVistied.BeginInvoke(new object[] { accountID, articlePartID }, null, null);

            return result;
        }

        private List<I> RequestTopHitArticle(int accountID)
        {
            List<I> result = new List<I>();

            // Get top hit article
            List<I> lstHit = GetTopArticle(accountID, TOP_ARTICLE_ON_CATEGORY);
            result.AddRange(lstHit);

            return result;
        }

        private List<I> RequestFavoriteArticle(int accountID, int pageIndex, int pageSize)
        {
            List<I> result = new List<I>();
            int cOut = 0;

            List<ArticleEntity> lstArt = bizArticle.GetListFavoriteArticleModel(accountID, pageIndex, pageSize, ref cOut);
            List<I> lstTmp = ParsingArticleModel(lstArt);

            result.Add(WSUtils.GetCounterItem(cOut));

            //Add article model
            result.AddRange(lstTmp);

            return result;
        }

        private List<I> RequestFavoriteAdd(int accountID, string password, int articleID)
        {
            // Add favorite
            AsynchronousHandler handlerAdd = new AsynchronousHandler(ProcessAddFavorite);
            handlerAdd.BeginInvoke(new object[] { accountID, password, articleID }, null, null);

            return new List<I>();
        }

        private List<I> RequestFavoriteDelete(int accountID, string password, int articleID)
        {
            // Delete favorite
            AsynchronousHandler handlerDelete = new AsynchronousHandler(ProcessDeleteFavorite);
            handlerDelete.BeginInvoke(new object[] { accountID, password, articleID }, null, null);

            return new List<I>();
        }

        private List<I> RequestFavoriteDeleteAll(int accountID, string password)
        {
            // Delete favorite
            AsynchronousHandler handlerDeleteAll = new AsynchronousHandler(ProcessDeleteAllFavorite);
            handlerDeleteAll.BeginInvoke(new object[] { accountID, password }, null, null);

            return new List<I>();
        }

        private List<I> RequestDownload(int accountID, string password, int articlePartID)
        {
            if (bizAccount.ValidateUser(accountID, password))
            {
                List<I> result = new List<I>();
                I enI = new I();
                Guid url = Guid.NewGuid();
                enI.n = string.Format(GlobalParam.DownloadUrl, url.ToString());
                enI.y = ((int)WSConstants.ContentType.Download).ToString();
                result.Add(enI);

                return result;
            }
            else
            {
                return new List<I>();
            }
        }

        private List<I> RequestRating(int accountID, string password, int articleID, int ratingPoint)
        {
            // Process rating
            AsynchronousHandler handlerRating = new AsynchronousHandler(ProcessRating);
            handlerRating.BeginInvoke(new object[] { accountID, password, articleID, ratingPoint }, null, null);

            return new List<I>();
        }

        private List<I> RequestSearchArticle(int accountID, string keyword, int pageIndex, int pageSize)
        {
            List<I> result = new List<I>();
            int cOut = 0;
            List<I> lstTmp = SearchArticle(accountID, keyword, pageIndex, pageSize, ref cOut);

            //Add counter item
            result.Add(WSUtils.GetCounterItem(cOut));

            //Add article
            result.AddRange(lstTmp);

            return result;
        }

        private List<L> RequestLogin(string username, string password)
        {
            List<L> result = new List<L>();
            L enL = new L();
            AccountBiz bizAccount = new AccountBiz();

            AccountEntity enAccount = bizAccount.GetAccountByUserName(username);
            string strMessage = string.Empty;
            if (enAccount == null)
            {
                enL.msg = GlobalParam.NotRegisedMessage;
                enL.i = "0";
                result.Add(enL);
                return result;
            }
            else
            {
                if (!enAccount.AccountName.Equals(username))
                {
                    enL.msg = GlobalParam.LoginFail;
                    enL.i = "0";
                    result.Add(enL);
                    return result;
                }
            }
            enL.i = enAccount.AccountID.ToString();

            result.Add(enL);

            return result;
        }

        private List<L> RequestUserChangePass(string username, string oldPass, string newPass)
        {
            List<L> result = new List<L>();
            L enL = new L();
            AccountBiz bizAccount = new AccountBiz();

            AccountEntity enAccount = bizAccount.GetAccountByUserName(username);
            string strMessage = string.Empty;
            if (enAccount == null)
            {
                enL.msg = GlobalParam.ChangePassFail;
                result.Add(enL);
                return result;
            }
            else
            {
                if (!enAccount.AccountName.Equals(oldPass))
                {
                    enL.msg = GlobalParam.ChangePassFail;
                    enL.i = "0";
                    result.Add(enL);
                    return result;
                }
            }

            enAccount.Passwd = newPass;
            int updateResult = bizAccount.UpdateAccount(enAccount);
            if (updateResult > 0)
            {
                enL.msg = GlobalParam.ChangePassSuccess;
                enL.i = enAccount.AccountID.ToString();
                result.Add(enL);
                return result;
            }
            else
            {
                enL.msg = GlobalParam.ChangePassFail;
                enL.i = "0";
                result.Add(enL);
                return result;
            }
        }

        private List<L> RequestUserInfo(string username, string password)
        {
            List<L> result = new List<L>();
            L enL = new L();
            AccountBiz bizAccount = new AccountBiz();

            AccountEntity enAccount = bizAccount.GetAccountByUserName(username);
            if (enAccount == null)
            {
                enL.msg = GlobalParam.InvalidRequest;
                enL.i = "0";
            }
            else
            {
                enL.i = enAccount.AccountID.ToString();
                enL.m = Utility.OptimizePhoneNumber(enAccount.Mobile);
                enL.r = enAccount.RegisterDateTime.HasValue ? enAccount.RegisterDateTime.Value.ToString("dd/MM/yyyy") : string.Empty;
            }
            result.Add(enL);
            return result;
        }

        private List<L> RequestUserRegister(string username, string password, string email)
        {
            List<L> result = new List<L>();
            L enL = new L();
            AccountBiz bizAccount = new AccountBiz();

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
            {
                enL.msg = GlobalParam.RegisterFail;
                enL.i = "0";
                result.Add(enL);
                return result;
            }

            AccountEntity enAccount = bizAccount.GetAccountByEmail(email);
            if (enAccount != null)
            {
                enL.msg = GlobalParam.EmailExist;
                enL.i = "0";
                result.Add(enL);
                return result;
            }

            enAccount = bizAccount.GetAccountByUserName(username);
            if (enAccount != null)
            {
                enL.msg = GlobalParam.AccountExist;
                enL.i = "0";
                result.Add(enL);
                return result;
            }
            else
            {
                int accoundID = bizAccount.Register(username, password, email);
                if (accoundID > 0)
                {
                    //push into param
                    enL.msg = GlobalParam.RegisterSuccess;
                    enL.i = accoundID.ToString();
                }
                else
                {
                    //push into param
                    enL.msg = GlobalParam.RegisterFail;
                    enL.i = "0";
                }

                result.Add(enL);
                return result;
            }
        }

        private List<L> RequestUserGetPassword(string email)
        {
            List<L> result = new List<L>();
            L enL = new L();

            AccountBiz bizAccount = new AccountBiz();

            AccountEntity enAccount = bizAccount.GetAccountByEmail(email);
            if (enAccount == null)
            {
                enL.msg = GlobalParam.EmailNotExist;
            }
            else
            {
                enL.msg = GlobalParam.SendPasswordToEmailSuccess;
            }
            result.Add(enL);
            return result;
        }
        #endregion Process Method

        #region private method

        private List<I> GetCategory(int parentID)
        {
            using (CategoryBiz bizCategory = new CategoryBiz())
            {
                List<I> result = new List<I>();
                List<CategoryEntity> lstCat = bizCategory.GetCategory(parentID);
                foreach (CategoryEntity item in lstCat)
                {
                    I en = new I();
                    en.i = item.CategoryID.ToString();
                    en.n = item.CategoryName;
                    if (item.CategoryCounter != 0)
                    {
                        en.c = "-" + item.CategoryCounter.ToString();
                    }
                    else
                    {
                        en.c = item.ArticleCounter.ToString();
                    }
                    en.y = ((int)WSConstants.ContentType.Category).ToString();
                    result.Add(en);
                }
                return result;
            }
        }

        /// <summary>
        /// Get top hit articles in a category
        /// </summary>
        /// <param name="rootCategoryID"></param>
        /// <returns></returns>
        private List<I> GetTopArticle(int accountID, int numberArticle)
        {
            List<ArticleEntity> lstArt = bizArticle.GetTopArticle(accountID, numberArticle);
            return ParsingArticleModel(lstArt);
        }

        /// <summary>
        /// Get list article in a category
        /// </summary>
        /// <param name="categoryID">CategoryID</param>
        /// <param name="pageNumber">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <returns></returns>
        private List<I> GetListArticle(int accountID, int categoryID, int pageIndex, int pageSize, ref int counter)
        {
            List<ArticleEntity> lstArt = bizArticle.GetListArticleByPage(accountID, categoryID, pageIndex, pageSize, ref counter);
            return ParsingArticleModel(lstArt);
        }

        /// <summary>
        /// Search article
        /// </summary>
        /// <param name="keyword">Key word to search</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <returns></returns>
        private List<I> SearchArticle(int accountID, string keyword, int pageIndex, int pageSize, ref int counter)
        {
            List<ArticleEntity> lstArt = bizArticle.SearchListArticle(accountID, keyword, pageIndex, pageSize, ref counter);
            return ParsingArticleModel(lstArt);
        }

        /// <summary>
        /// Get article model by article id
        /// </summary>
        /// <param name="articleID"></param>
        /// <returns></returns>
        private I GetArticleByID(int articleID)
        {
            I result = null;
            ArticleEntity mdArticle = bizArticle.GetArticleByID(articleID);
            if (mdArticle != null)
            {
                List<ArticleEntity> lstModel = new List<ArticleEntity>() { mdArticle };
                result = ParsingArticleModel(lstModel)[0];
            }
            return result;
        }

        /// <summary>
        /// Get list of article part
        /// </summary>
        /// <param name="partID"></param>
        /// <returns></returns>
        private List<I> GetListArticlePart(int accountID, int articleID, int pageIndex, int pageSize, ref int counter)
        {
            List<ArticlePartEntity> lstPart = bizArticlePart.GetArticlePartByPage(accountID, articleID, pageIndex, pageSize, ref counter);
            return ParsingArticlePartModel(lstPart);
        }

        #endregion

        #region Parsing methods

        private List<I> ParsingArticleModel(List<ArticleEntity> lstModel)
        {
            if (lstModel == null)
                return new List<I>();

            List<I> result = new List<I>();
            foreach (ArticleEntity item in lstModel)
            {
                I en = new I();
                en.i = item.ArticleID.ToString();
                en.n = item.ArticleName;
                en.d = string.Format("{0} phần", item.PartCounter);
                en.c = item.PartCounter.ToString();
                en.m = item.Visited.ToString();
                en.o = string.Format("Cập nhật: {0}", item.LastTimeUpdate.ToString("dd/MM/yy hh:mm"));
                //Assign rate star
                int rateStar = 0;
                if (item.RatePoint != 0)
                {
                    rateStar = item.RatePoint;
                }
                if (rateStar <= 0 || rateStar > MAX_RATE)
                {
                    rateStar = DEFAULT_RATE;
                }
                en.r = rateStar.ToString();

                en.y = ((int)WSConstants.ContentType.Article).ToString();
                result.Add(en);
            }
            return result;
        }

        private List<I> ParsingArticlePartModel(List<ArticlePartEntity> lstModel)
        {
            TimeSpan time;
            List<I> result = new List<I>();
            foreach (ArticlePartEntity item in lstModel)
            {
                I en = new I();
                en.i = item.ArticlePartID.ToString();
                en.n = item.ArticlePartName;
                en.c = item.PartCounter.ToString();
                time = new TimeSpan(0, 0, item.Duration);
                en.o = item.Duration.ToString() + Constant.SEPARATER_CHAR + item.FileSize.ToString(); //format: duration/filesize/price

                en.m = item.Visited.ToString();
                en.y = ((int)WSConstants.ContentType.ArticlePart).ToString();
                result.Add(en);
            }
            return result;
        }

        #endregion


        #region Asynchronous methods

        /// <summary>
        /// Required param = {int accountID, int articleID}
        /// </summary>
        /// <param name="param"></param>
        private void ProcessVisitedArticle(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                int articleID = (int)param[1];

                // Increase play counter
                bizArticle.IncreasePlayCounter(articleID);

                // Add visited item
                VisitedEntity enVisited = bizVisited.GetVisited(accountID, articleID, (int)Constant.ItemType.Article);
                if (enVisited == null)
                {
                    enVisited = new VisitedEntity();
                    enVisited.AccountID = accountID;
                    enVisited.ItemID = articleID;
                    enVisited.ItemTypeID = (int)Constant.ItemType.Article;
                    enVisited.CreatedDateTime = DateTime.Now;
                    bizVisited.AddVisited(enVisited);
                }
            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// Required param = {int accountID, int articlePartID}
        /// </summary>
        /// <param name="param"></param>
        private void ProcessVisitedArticlePart(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                int articlePartID = (int)param[1];
                VisitedEntity enVisited = bizVisited.GetVisited(accountID, articlePartID, (int)Constant.ItemType.ArticlePart);
                if (enVisited == null)
                {
                    enVisited = new VisitedEntity();
                    enVisited.AccountID = accountID;
                    enVisited.ItemID = articlePartID;
                    enVisited.ItemTypeID = (int)Constant.ItemType.ArticlePart;
                    enVisited.CreatedDateTime = DateTime.Now;
                    bizVisited.AddVisited(enVisited);
                }
            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// Required param = {int accountID, string password, int articleID}
        /// </summary>
        /// <param name="param"></param>
        private void ProcessAddFavorite(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                string password = (string)param[1];
                int articleID = (int)param[2];
                if (bizAccount.ValidateUser(accountID, password))
                {
                    if (!bizFavorite.CheckExistItemID(accountID, articleID, (int)Constant.ItemType.Article))
                    {
                        FavoriteEntity enFavorite = new FavoriteEntity();
                        enFavorite.ItemID = articleID;
                        enFavorite.AccountID = accountID;
                        enFavorite.ItemType = (int)Constant.ItemType.Article;
                        enFavorite.CreatedDateTime = DateTime.Now;
                        bizFavorite.AddFavorite(enFavorite);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// Required param = {int accountID, string password, int articleID}
        /// </summary>
        /// <param name="accountID"></param>
        /// <param name="password"></param>
        /// <param name="articleID"></param>
        private void ProcessDeleteFavorite(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                string password = (string)param[1];
                int articleID = (int)param[2];
                if (bizAccount.ValidateUser(accountID, password))
                {
                    bizFavorite.DeleteFavorite(accountID, articleID, (int)Constant.ItemType.Article);
                }
            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// Required param = {int accountID, string password}
        /// </summary>
        private void ProcessDeleteAllFavorite(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                string password = (string)param[1];
                if (bizAccount.ValidateUser(accountID, password))
                {
                    bizFavorite.DeleteFavoriteByAccountID(accountID, (int)Constant.ItemType.Article);
                }
            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// Required param = {int accountID, string password, int articleID, int ratingPoint}
        /// </summary>
        /// <param name="param"></param>
        private void ProcessRating(object[] param)
        {
            try
            {
                int accountID = (int)param[0];
                string password = (string)param[1];
                int articleID = (int)param[2];
                int ratingPoint = (int)param[3];
                if (bizAccount.ValidateUser(accountID, password))
                {
                    if (ratingPoint <= 5 && ratingPoint >= 1)
                    {
                        bizArticle.RateArticle(articleID, ratingPoint);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }

        #endregion

    }
}
